package com.chub.study.modules.dto;

import cn.hutool.core.date.DatePattern;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.DateDeserializers;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;
import org.apache.tomcat.jni.Local;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author : chub
 * @version : V1.0.0
 * @fileName : DateReq.java
 * @description : TODO
 * @createTime : 2024-07-31 16:21
 */
@Data
public class DateReq {

    // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = "GMT+8")
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)

    //将city对象以JSON格式进行序列化为String对象
    //System.out.println("注解@JsonFormat主要是后台到前台的时间格式的转换 观察TCity.getCrtTime()方法的注解:   @JsonFormat()、@JsonSerialize");

    //将JSON字符串反序列化为java对象
    //System.out.println("注解@DateTimeFormat主要是前后到后台的时间格式的转换 观察TCity.setCrtTime()方法的注解:   @JsonDeserialize()");

    private String strDate;

    @DateTimeFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8")
    private java.util.Date utilDate;

    // @JsonFormat 可将前端传入的“yyyy-MM-dd”格式日期转成“java.sql.Date的”字符串形式“2024-03-02”
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8")
    private java.sql.Date sqlDate;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    private java.sql.Timestamp sqlTimestamp;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
    private LocalDate  localDate;

    @DateTimeFormat(pattern = DatePattern.NORM_DATE_PATTERN)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DatePattern.NORM_DATE_PATTERN, timezone = "GMT+8")
    private LocalDateTime localDateTime;

}
